import { createBrowserRouter } from "react-router-dom";
import App from "../App";

export const childrenList=[
    {
        path:'index',
        title:'首页',
        lazy:async()=>{
            const{default:Index}=await import('../pages/index/Index')
            return{
                element:<Index/>
            }
        }
    },
    {
        path:'order',
        title:'订单',
        lazy:async()=>{
            const{default:Order}=await import('../pages/order/Index')
            return{
                element:<Order/>
            }
        }
    },
    {
        path:'message',
        title:'消息',
        lazy:async()=>{
            const{default:Message}=await import('../pages/message/Index')
            return{
                element:<Message/>
            }
        }
    },
    {
        path:'user',
        title:'用户',
        lazy:async()=>{
            const{default:User}=await import('../pages/user/Index')
            return{
                element:<User/>
            }
        },
        children:[
            {
                path:'my',
                title:'我的',
                lazy:async()=>{
                    const{default:My}=await import('../pages/user/my/Index')
                    return{
                        element:<My/>
                    }
        },
            }
        ]
    }
]

const routes=createBrowserRouter([
    {
        path:'/',
        element:<App/>,
        children:childrenList
    }
])
export default routes